import time

from django.conf import settings
from django.core.mail import send_mail

from celery_test.main import app
from meiduo1.libs.yuntongxun.sms import CCP


@app.task(bind=True,name='haha')
def email_url(self,varyfie,email):#这的时间按分钟计算
    restu = -1
    try:
        restu = send_mail(subject='美多商城',
                  message=varyfie,
                  from_email=settings.EMAIL_FROM,
                  recipient_list=[email])
    except Exception as e:
        restu = -1

    if restu == -1:
        print('重试中...')
        self.retry(countdown=5,max_retries=3,etc='发送邮件失败了')#countdown表示隔得秒数发一次，第二个表示发几次，第三个抛出的异常信息